package com.neuedu.web.dao;

import com.neuedu.web.common.BaseDao;
import com.neuedu.web.po.RoleMenuPO;
import com.neuedu.web.po.UserRolePO;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @author 金山
 * 项目：jdbc-dao
 * site: https://blog.fulfill.com.cn
 * 描述  dept 表的数据访问对象
 * @data  2024年11月21日13:38:03
 */
public class RoleMenuDao extends BaseDao<RoleMenuPO> {



    public List<RoleMenuPO> selectAll(  String sql, Object... params) throws NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        return super.selectAll(RoleMenuPO.class , sql,params);
    }








    public int insert(RoleMenuPO po) {
        String sql = "INSERT INTO `role_menu` (   `menu_id`, `role_id`) VALUES(  ?,? )  ";
        int count = super.update(sql,
                po.getMenuId(),
                po.getRoleId()
        );

        return count;

    }


    /**
     * 根据用户 id 删除已经授权的橘色
     * @param roleId
     * @return
     */
    public int deleteByRoleId(Long roleId) {
        String sql = "delete from  `role_menu`  where  role_id = ? ";
        int count = super.update(sql,roleId );

        return count;
    }



}
